'use strict';
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	console.log('开始登陆')
	var that = this
	uni.showModal({
				mask: true,
				title: '温馨提示',
				content: '授权微信登录后才能正常使用小程序功能',
				success(res) {
					if (res.confirm) {
						uni.getUserProfile({
							desc: '获取你的昵称、头像',
							success: userRes => {
								if (userRes.errMsg == 'getUserProfile:ok' && userRes.userInfo != undefined) {
									var userInfo = {
										avatarUrl: userRes.userInfo.avatarUrl,
										nickName: userRes.userInfo.nickName
									}
									that.getUserOpenId(userInfo)
								} else {
									uni.showToast({
										icon:"none",
										title:"获取失败，请重试"
									})
								}
							},
							fail: error => {}
						});
					} else if (res.cancel) {}
				}
			});
			uni.login({
				provider: 'weixin',
				success(loginAuth) {
					var data = {'code':loginAuth.code}
					console.log(data)
					var path = 'http://42.193.152.244/login'
					console.log(path)
					uni.request({
						url:path,
						data:data,
						success(res){
							console.log(res)
							userInfo['openid'] = res
						}
					})
					console.log(userInfo)
					console.log('结束')
				}
			})
			return userInfo
		};
		
		
	
	//返回数据给客户端
